home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / pcq_incl3v1.lha / Graphics / Text.i < prev    next >
Encoding:
Text File  |  1994-04-15  |  8.3 KB  |  222 lines

  1. {
  2.     Text.i for PCQ Pascal
  3. }
  4.  
  5. {$I   "Include:Graphics/Gfx.i"}
  6. {$I   "Include:Exec/Ports.i"}
  7. {$I   "Include:Utility/TagItem.i"}
  8.  
  9. const
  10.  
  11. {------ Font Styles ------------------------------------------------}
  12.  
  13.     FS_NORMAL           = 0;    { normal text (no style bits set) }
  14.     FSB_EXTENDED        = 3;    { extended face (wider than normal) }
  15.     FSF_EXTENDED        = 8;
  16.     FSB_ITALIC          = 2;    { italic (slanted 1:2 right) }
  17.     FSF_ITALIC          = 4;
  18.     FSB_BOLD            = 1;    { bold face text (ORed w/ shifted) }
  19.     FSF_BOLD            = 2;
  20.     FSB_UNDERLINED      = 0;    { underlined (under baseline) }
  21.     FSF_UNDERLINED      = 1;
  22.  
  23.     FSB_COLORFONT       = 6;       { this uses ColorTextFont structure }
  24.     FSF_COLORFONT       = $40;
  25.     FSB_TAGGED          = 7;       { the TextAttr is really an TTextAttr, }
  26.     FSF_TAGGED          = $80;
  27.  
  28.  
  29. {------ Font Flags -------------------------------------------------}
  30.     FPB_ROMFONT         = 0;    { font is in rom }
  31.     FPF_ROMFONT         = 1;
  32.     FPB_DISKFONT        = 1;    { font is from diskfont.library }
  33.     FPF_DISKFONT        = 2;
  34.     FPB_REVPATH         = 2;    { designed path is reversed (e.g. left) }
  35.     FPF_REVPATH         = 4;
  36.     FPB_TALLDOT         = 3;    { designed for hires non-interlaced }
  37.     FPF_TALLDOT         = 8;
  38.     FPB_WIDEDOT         = 4;    { designed for lores interlaced }
  39.     FPF_WIDEDOT         = 16;
  40.     FPB_PROPORTIONAL    = 5;    { character sizes can vary from nominal }
  41.     FPF_PROPORTIONAL    = 32;
  42.     FPB_DESIGNED        = 6;    { size is "designed", not constructed }
  43.     FPF_DESIGNED        = 64;
  44.     FPB_REMOVED         = 7;    { the font has been removed }
  45.     FPF_REMOVED         = 128;
  46.  
  47. {***** TextAttr node, matches text attributes in RastPort *********}
  48.  
  49. type
  50.  
  51.     TextAttr = record
  52.         ta_Name : String;       { name of the font }
  53.         ta_YSize : Short;       { height of the font }
  54.         ta_Style : Byte;        { intrinsic font style }
  55.         ta_Flags : Byte;        { font preferences and flags }
  56.     end;
  57.     TextAttrPtr = ^TextAttr;
  58.  
  59.     TTextAttr = record
  60.         tta_Name : String;       { name of the font }
  61.         tta_YSize : Short;       { height of the font }
  62.         tta_Style : Byte;        { intrinsic font style }
  63.         tta_Flags : Byte;        { font preferences AND flags }
  64.         tta_Tags  : Address;     { extended attributes }
  65.     end;
  66.     TTextAttrPtr = ^TTextAttr;
  67.  
  68. {***** Text Tags **************************************************}
  69. CONST
  70.   TA_DeviceDPI  =  (1+TAG_USER);    { Tag value is Point union: }
  71.                                         { Hi word XDPI, Lo word YDPI }
  72.  
  73.   MAXFONTMATCHWEIGHT  =    32767;   { perfect match from WeighTAMatch }
  74.  
  75.  
  76.  
  77. {***** TextFonts node *********************************************}
  78. Type
  79.     TextFont = record
  80.         tf_Message      : Message;      { reply message for font removal }
  81.                                         { font name in LN \    used in this }
  82.         tf_YSize        : Short;        { font height     |    order to best }
  83.         tf_Style        : Byte;         { font style      |    match a font }
  84.         tf_Flags        : Byte;         { preferences and flags /    request. }
  85.         tf_XSize        : Short;        { nominal font width }
  86.         tf_Baseline     : Short; { distance from the top of char to baseline }
  87.         tf_BoldSmear    : Short;        { smear to affect a bold enhancement }
  88.  
  89.         tf_Accessors    : Short;        { access count }
  90.  
  91.         tf_LoChar       : Byte;         { the first character described here }
  92.         tf_HiChar       : Byte;         { the last character described here }
  93.         tf_CharData     : Address;      { the bit character data }
  94.  
  95.         tf_Modulo       : Short; { the row modulo for the strike font data }
  96.         tf_CharLoc      : Address; { ptr to location data for the strike font }
  97.                                         { 2 words: bit offset then size }
  98.         tf_CharSpace    : Address; { ptr to words of proportional spacing data }
  99.         tf_CharKern     : Address;      { ptr to words of kerning data }
  100.     end;
  101.     TextFontPtr = ^TextFont;
  102.  
  103.  
  104. {----- tfe_Flags0 (partial definition) ----------------------------}
  105. CONST
  106.  TE0B_NOREMFONT = 0;       { disallow RemFont for this font }
  107.  TE0F_NOREMFONT = $01;
  108.  
  109. Type
  110.    TextFontExtension = Record              { this structure is read-only }
  111.     tfe_MatchWord  : Short;                { a magic cookie for the extension }
  112.     tfe_Flags0     : Byte;                 { (system private flags) }
  113.     tfe_Flags1     : Byte;                 { (system private flags) }
  114.     tfe_BackPtr    : TextFontPtr;          { validation of compilation }
  115.     tfe_OrigReplyPort : MsgPortPtr;        { original value in tf_Extension }
  116.     tfe_Tags       : Address;              { Text Tags for the font }
  117.     tfe_OFontPatchS,                       { (system private use) }
  118.     tfe_OFontPatchK : Address;             { (system private use) }
  119.     { this space is reserved for future expansion }
  120.    END;
  121.    TextFontExtensionPtr = ^TextFontExtension;
  122.  
  123. {***** ColorTextFont node *****************************************}
  124. {----- ctf_Flags --------------------------------------------------}
  125. CONST
  126.  CT_COLORMASK  =  $000F;  { mask to get to following color styles }
  127.  CT_COLORFONT  =  $0001;  { color map contains designer's colors }
  128.  CT_GREYFONT   =  $0002;  { color map describes even-stepped }
  129.                                 { brightnesses from low to high }
  130.  CT_ANTIALIAS  =  $0004;  { zero background thru fully saturated char }
  131.  
  132.  CTB_MAPCOLOR  =  0;      { map ctf_FgColor to the rp_FgPen IF it's }
  133.  CTF_MAPCOLOR  =  $0001;  { is a valid color within ctf_Low..ctf_High }
  134.  
  135. {----- ColorFontColors --------------------------------------------}
  136. Type
  137.    ColorFontColors = Record
  138.     cfc_Reserved,                 { *must* be zero }
  139.     cfc_Count   : Short;          { number of entries in cfc_ColorTable }
  140.     cfc_ColorTable : Address;     { 4 bit per component color map packed xRGB }
  141.    END;
  142.    ColorFontColorsPtr = ^ColorFontColors;
  143.  
  144. {----- ColorTextFont ----------------------------------------------}
  145.    ColorTextFont = Record
  146.     ctf_TF      : TextFontPtr;
  147.     ctf_Flags   : Short;          { extended flags }
  148.     ctf_Depth,          { number of bit planes }
  149.     ctf_FgColor,        { color that is remapped to FgPen }
  150.     ctf_Low,            { lowest color represented here }
  151.     ctf_High,           { highest color represented here }
  152.     ctf_PlanePick,      { PlanePick ala Images }
  153.     ctf_PlaneOnOff : Byte;     { PlaneOnOff ala Images }
  154.     ctf_ColorFontColors : ColorFontColorsPtr; { colors for font }
  155.     ctf_CharData : Array[0..7] of APTR;    {pointers to bit planes ala tf_CharData }
  156.    END;
  157.    ColorTextFontPtr = ^ColorTextFont;
  158.  
  159. {***** TextExtent node ********************************************}
  160.    TextExtentStruct = Record
  161.     te_Width,                   { same as TextLength }
  162.     te_Height : Short;          { same as tf_YSize }
  163.     te_Extent : Rectangle;      { relative to CP }
  164.    END;
  165.    TextExtentPtr = ^TextExtentStruct;
  166.  
  167.  
  168. Procedure AddFont(textFont : TextFontPtr);
  169.     External;
  170.  
  171. Procedure AskFont(rp : Address; textAttr : TextAttrPtr);
  172.     External;   { rp is a RastPortPtr }
  173.  
  174. Function AskSoftStyle(rp : Address) : Integer;
  175.     External;   { rp is a RastPortPtr }
  176.  
  177. Procedure ClearEOL(rp : Address);
  178.     External;
  179.  
  180. Procedure ClearScreen(rp : Address);
  181.     External;
  182.  
  183. Procedure CloseFont(font : TextFontPtr);
  184.     External;
  185.  
  186. FUNCTION ExtendFont(F : TextFontPtr; TagList : Address) : Integer;
  187.     External;
  188.  
  189. PROCEDURE FontExtent(F : TextFontPtr; TE : TextExtentPtr);
  190.     External;
  191.  
  192. Function OpenFont(textAttr : TextAttrPtr) : TextFontPtr;
  193.     External;
  194.  
  195. Procedure RemFont(textFont : TextFontPtr);
  196.     External;
  197.  
  198. Procedure SetFont(rp : Address; font : TextFontPtr);
  199.     External;   { rp is a RastPortPtr }
  200.  
  201. Function SetSoftStyle(rp : Address; style, enable : Integer) : Integer;
  202.     External;
  203.  
  204. PROCEDURE StripFont(f : TextFontPtr);
  205.     External;
  206.  
  207. Procedure GText(rp : Address; str : String; count : Short);
  208.     External;
  209.  
  210. PROCEDURE TextExtent(RP : Address; str : String; count : Short; TE : TextExtentPtr);
  211.     External;
  212.  
  213. FUNCTION TextFit(RP : Address; Str : String; StrLen : Short; TE , CET : TextExtentPtr;
  214.                  Direction, BitWidth, BitHeight : Short) : Integer;
  215.     External;
  216.  
  217. Function TextLength(rp : Address; str : String; count : Short) : Short;
  218.     External;
  219.  
  220. FUNCTION WeighTAMatch(ReqTextAttr : TTextAttrPtr; targetTextAttr : TextAttrPtr; TagList : Address) : Short;
  221.     External;
  222.